/******************************
 * @Developer: many
 * @File: fix.go
 * @Time: 2022/5/13 14:51
******************************/

package hooks

import (
	"github.com/sirupsen/logrus"
	"logger/fixopt"
)

var hookinstaller []func(opt ...*fixopt.Field) (logrus.Hook, error)

func WithHooks(opt ...*fixopt.Field) (logrus.LevelHooks, error) {
	hooks := make(logrus.LevelHooks)
	for i := range hookinstaller {
		if hook, err := hookinstaller[i](opt...); err != nil {
			return nil, err
		} else if hook != nil {
			hooks.Add(hook)
		}
	}

	return hooks, nil
}
